package com.matt.docpro.service;

import com.matt.docpro.mapper.*;
import com.matt.docpro.model.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * AppointmentService
 * Created by on 2024/02/20.
 */
@Service
public class LoginInfoService {

    @Autowired
    LoginInfoMapper loginInfoMapper;
    @Autowired
    UserMapper userMapper;

    public void insert(LoginInfo loginInfo) {
        loginInfoMapper.insert(loginInfo);
    }

    public User getUserByToken(String token) {
        if (token == null) return null;
        LoginInfo loginInfo = loginInfoMapper.getByToken(token);
        if (loginInfo == null) return null;
        return userMapper.getById(loginInfo.getUserId());
    }

    public void delete() {
        loginInfoMapper.delete();
    }

}
